<template>
  <div class="Home">
  
    <div class="car">
  <el-carousel indicator-position="outside" height="420px">
    <el-carousel-item v-for="el in carArr" :key="el.id">
      <router-link :to="'/detailCar/'+el.id">
        <img :src="el.src" alt="" height="420">
      </router-link>
    </el-carousel-item>
  </el-carousel>
    </div>

    <div class="carbottom">
      <aside></aside>
    </div>
    <div class="headnews">
   
    <el-row :style="{width:$store.state.screenWidth+'px'}">
  <el-divider>
      <router-link to="/list/headlines" style="text-decoration: none;color: aliceblue;">
      <h1>头条关注 <el-icon class="is-loading" style="vertical-align: middle;">
    <Loading />
  </el-icon>
  </h1>
  </router-link>
    </el-divider>
   <el-col
      v-for="el in hnewsArr" 
      :key="el.id"
      :span="6"
    >
   <router-link :to="'/detail/headlines/'+el.id" style="text-decoration: none;position: relative;">
      <el-card :body-style="{ padding: '0px' }">
        <img
          :src="el.src"
          class="image"
        />
        <div style="padding: 0px 10px">
          <span><h4 v-text="el.title"></h4></span>
          <div class="bottom" style="position: absolute;right: 10px;bottom: 10px;">
          
            <img src="@/assets/img/more3.png" alt="" style="width: 32px;height: 30px;">
          </div>
        </div>
      </el-card>
    </router-link>
    </el-col>

  </el-row>
  </div>
   <div class="headnews comnews">
  
    <el-row :style="{width:$store.state.screenWidth+'px'}">
   <el-divider style="margin-bottom: 25px;">
            <router-link to="/list/comprehensive" style="text-decoration: none;color: rgb(8, 45, 94);">
      <h1>综合新闻 <el-icon class="is-loading" style="vertical-align: middle;">
    <Loading />
  </el-icon>
  </h1> </router-link>
    </el-divider>
   <el-col
      v-for="el in cNewsArr" 
      :key="el.id"
      :span="6"
    >
   <router-link :to="'/detail/comprehensive/'+el.id" style="text-decoration: none;position: relative;">
      <el-card :body-style="{ padding: '0px' }">
        <img
          :src="el.src"
          class="image"
        />
        <div style="padding: 0px 10px">
          <span><h4 v-text="el.title"></h4></span>
          <article style="overflow: hidden;"><p v-text="el.param"></p></article>
          <div class="bottom" style="position: absolute;right: 135px;bottom: 10px;">
          
            <img src="@/assets/img/more3.png" alt="" style="width: 32px;height: 30px;">
          </div>
        </div>
      </el-card>
    </router-link>
    </el-col>

  </el-row>
  </div>
   <div class="headnews comnews learning">
     
    <el-row :style="{width:$store.state.screenWidth+'px'}">
<el-divider >
       <router-link to="/list/learning" style="text-decoration: none;color: rgb(8, 45, 94);">
      <h1>学术动态 <el-icon class="is-loading" style="vertical-align: middle;">
    <Loading />
  </el-icon> 
  </h1></router-link>
    </el-divider>
   <el-col
      v-for="el in learnArr" 
      :key="el.id"
      :span="6"
    >
   <router-link :to="'/detail/learning/'+el.id" style="text-decoration: none;position: relative;">
      <el-card :body-style="{ padding: '0px' }">
       
        <div style="padding: 0px 10px">
          <span><h4 v-text="el.title"></h4></span>
          <article style="overflow: hidden;"><p v-text="el.param"></p></article>
         
        </div>
      </el-card>
    </router-link>
    </el-col>

  </el-row>
  </div>
     <div class="learning  story">
   
    <el-row :style="{width:$store.state.screenWidth+'px'}">
  <el-divider style="margin-bottom: 40px;">
             <router-link to="/list/story" style="text-decoration: none;color: aliceblue;">

      <h1>师大故事 <el-icon class="is-loading" style="vertical-align: middle;">
    <Loading />
  </el-icon>
  </h1></router-link>
    </el-divider>
   <el-col
      v-for="el in storyArr" 
      :key="el.id"
      :span="6"
    >
   <router-link :to="'/detail/story/'+el.id" style="text-decoration: none;position: relative;">
      <el-card :body-style="{ padding: '0px' }">
         <img
          :src="el.src"
          class="image"
        />
        <div style="padding: 0px 10px">
          <span><h4 v-text="el.title"></h4></span>
          <article style="overflow: hidden;"><p v-text="el.param"></p></article>
         
        </div>
      </el-card>
    </router-link>
    </el-col>

  </el-row>
  </div>
  <div class="thelast">
    <el-row :style="{width:$store.state.screenWidth+'px'}" >
      <el-col :span="11" class="notice">
        <el-divider style="margin-bottom: 40px;">
             <router-link to="/listnotice/notice" style="text-decoration: none;color: rgb(8, 45, 94);">

      <h1>通知公告 <el-icon class="is-loading" style="vertical-align: middle;">
    <Loading />
  </el-icon>
  </h1></router-link>
    </el-divider>
<el-card >

  <div class="box" :style="{height:boxHeight+'px'}" :scrollTop="moveUp" @mouseover="stop" @mouseout="start">

  <router-link :to="'/detailNotice/'+el.id" v-for="el in noticeArr" :key="el.id">
  <b v-text="el.index+'.'+ el.title"></b>
  <span v-text="el.date"></span>
    </router-link>
    </div>
  </el-card>
  
      </el-col>

<el-col :span="2"></el-col>

      <el-col :span="11" class="web">
  <el-divider>
             <router-link to="/list/web" style="text-decoration: none;color: rgb(8, 45, 94);">

      <h1>专题网站 <el-icon class="is-loading" style="vertical-align: middle;">
    <Loading />
  </el-icon>
  </h1></router-link>
    </el-divider>
    <el-row style="margin-top:45px ;" :gutter="15">
      <el-col :span="12" >
    <a href="http://www.baidu.com">
    <span><img src="@/assets/img/w1.jpg" alt=""></span>
      </a>
         </el-col>
 
     <el-col :span="12" >
    <a href="http://www.baidu.com">
    <span><img src="@/assets/img/w2.jpg" alt=""></span>
      </a>
         </el-col>  
     
     
   
       <el-col :span="12" style="margin-top:10px ; " >
        <a href="http://www.baidu.com">
        <span><img src="@/assets/img/w3.jpg" alt=""></span>
        </a>
      </el-col>
       
       
        <el-col :span="12" style="margin-top:10px ;">
        <a href="http://www.baidu.com">
      <span><img src="@/assets/img/w4.jpg" alt=""></span>
      </a>
      </el-col>
      </el-row>
   </el-col>
    
    </el-row>
  </div>
  </div>
 
   <el-backtop :bottom="100">
    <div
      style="
        height: 100%;
        width: 100%;
        background-color: var(--el-bg-color-overlay);
        box-shadow: var(--el-box-shadow-lighter);
        text-align: center;
        line-height: 45px;
        color: #1989fa;
        border-radius: 50%;
      "
    >
     <el-icon><ArrowUpBold /></el-icon>
    </div>
  </el-backtop>
</template>

<script>
export default {
  name: 'HomeCom',
  data(){
    return{
      carArr:[],
      hnewsArr:[],
      cNewsArr:[],
      learnArr:[],
      storyArr:[],
      noticeArr:[],
      boxHeight:290,
      moveUp:0,
      timer:null
    }
  },

  methods:{
    move(){
     this.timer=setInterval(()=>{
      if(this.moveUp===260){
        this.moveUp=0
      }else{
         this.moveUp++;
      }
     },20)
    },
    stop(){
      clearInterval(this.timer)
    },
    start(){
      this.move()
    }
  },
  mounted(){
    this.$axios.get('getData').then(rs=>{
      this.carArr=rs[0].map((el)=>{
 
        return {id:el.id,src:this.$store.state.URL+'adv/'+el.src}
       
      })
      this.hnewsArr=rs[1].map((el)=>{
        let src=el.content.match(/src="[^"]+"/)[0];
        src=src.substring(5,src.length-1);

        return {id:el.id,src,title:el.title}
      })
       this.cNewsArr=rs[2].map((el)=>{
        let src=el.content.match(/src="[^"]+"/)[0];
        src=src.substring(5,src.length-1);
        let param=el.content.match(/<p>[^>]+<\/p>/)[0];
        param=param.replace(/<[^>]+>/g,'');
        return {id:el.id,src,title:el.title,param}
      })
         this.learnArr=rs[3].map((el)=>{
      
        let param=el.content.match(/<p>[^>]+<\/p>/)[0];
        param=param.replace(/<[^>]+>/g,'');
        return {id:el.id,title:el.title,param}
      })
       this.storyArr=rs[4].map((el)=>{
        let src=el.content.match(/src="[^"]+"/)[0];
        src=src.substring(5,src.length-1);
       
        return {id:el.id,title:el.title,src}
        
      })
      
        let temp=rs[5].map((el,i)=>{
        let date=new Date(el.updatedAt).toLocaleDateString();
        return {index:i-0+1,id:el.id,title:el.title,date}
      })
      this.noticeArr=[...temp,...temp]//复制一段
     
      this.move();
      
      

    })
  },
  watch:{
    //  noticeArr:{
    //     deep:true,
    //     handler(){
     
    //       setTimeout(()=>{
    //          this.boxHeight=parseInt(this.$refs.box.offsetHeight/2);

           
    //       },10)
          
    //     }
    //   }
     
  }
 
}
</script>


<style scoped lang="less">
.Home{
  width: 100%;
  background-color: rgb(8, 45, 94);
  margin-top: 80px;
  .thelast{
    padding-bottom: 50px;
    width: 100%;
    background-color: #eaeef5;
    padding-top: 50px;
    .el-row{
      margin: auto;
      .notice{
        .el-card{
          background-color: #e2efff;
          .box {
            border-radius: 5px;
            background-color: #74d3f6;
            overflow-y: hidden;
             a{
            
            text-decoration: none;
            font-size: 14px;
            display: flex;
            justify-content: space-between;
            padding: 8px;
            color: #000000;
            
           
            
            &:hover,&:visited{
             
               color: rgb(16, 45, 103);
            }
            b{
              border-bottom: 1px dashed black;
              margin-right: 15px;
            font-weight: normal;
             overflow: hidden;
             text-overflow: ellipsis;
             white-space: nowrap;
            }
          
            
          }
          }
        }
      }
      .web{
   
       
         
          .el-col{ 
            
            a{
              display: block;
              position: relative;
                &::before{
                  content: "";
                  position: absolute;
                  border: 1px solid rgb(165, 161, 161);
                  transition: all 0.5s ease;
                  background: url(../assets/img/link.png) no-repeat center center;
                  left: 50%;
                  top: 50%;
                  height: 0;
                  width: 0;
                  z-index: 100;
                  opacity: 0;
                
                }
                 &:hover::before{
                    left: 0;
                    top: 0;
                    width: 99%;
                    opacity: 1;
                    height: 96%;
                    background-color: rgba(0,0,0,0.3);

                  }
              span{
                
                 img{
              width:100%;
              height: 157px;
           }
              }
            }
         
         
        
          
        }
       
      }
    }
  }
  .car{
  img{
    width: 100%;
  }
   
  }
  .carbottom{
    height: 48px;
    aside{
    height: 48px;
    background: url(../assets/img/line.png) no-repeat center center,
    url(../assets/img/gz_bg.png) no-repeat center top;
    margin-top: -20px;
   }
  }
  .headnews{
    width: 100%;
    background-color: rgb(8, 45, 94);
    margin-top: 50px;
    .el-divider{
      margin-bottom: 30px;

    }
    .el-row{
      margin: auto;
      .el-col{
        .el-card{
          height: 290px;
          margin-left:3px;
          margin-top: 10px;
          background-color: rgb(8, 45, 94);
          h4{
            color: aliceblue;
             display: -webkit-box;
          -webkit-box-orient: vertical;
          -webkit-line-clamp: 2;
          word-break: break-all;
          overflow: hidden;
          }
          img{
            width: 100%;
            height: 175px;
          }
        }
      }
    }
  }
  .comnews{
    background-color: #cce1fa;
    padding-top: 50px;
    padding-bottom: 50px;
    .el-row{
      
      .el-col{
        .el-card{
          height: 400px;
          background-color: aliceblue;
          // &:hover{
          //   padding-bottom: 20px;
          // }
          h4{
            border-bottom: 1px solid rgb(16, 83, 161);
            padding-bottom: 20px;
            font-weight: lighter;
            color: rgb(16, 83, 161);
       
          }
          p{
            font-size: 14px;
            margin-top: -20px;
            display: -webkit-box;
          -webkit-box-orient: vertical;
          -webkit-line-clamp: 3;
          word-break: break-all;
          overflow: hidden;
            
          }
   
         
        }
      }
    }
  }
  .learning{
    background-color: #eaeef5;
    margin-bottom: 0px;
    padding-top: 50px;
    margin-top: 0;
    padding-bottom: 55px;
    .el-row{
      
      .el-col{
        
        .el-card{
          margin-bottom: -8px;
          height: 190px;
        background-color: #e2efff;
          h4{
            color: #00a4df;
            border-bottom: none;
               display: -webkit-box;
          -webkit-box-orient: vertical;
          -webkit-line-clamp: 1;
          word-break: break-all;
          overflow: hidden;
            overflow: hidden;
            &:hover{
              color: #000000;
            }
          
          }
          p{
            font-size: 13px;
            margin-top: -20px;
            display: -webkit-box;
          -webkit-box-orient: vertical;
          -webkit-line-clamp: 6;
          word-break: break-all;
          overflow: hidden;
            &:hover{
              color: rgb(16, 45, 103);
            }
          }
   
         
        }
      }
    }
  }
   .story{
 background-color: rgb(8, 45, 94);;
    padding-bottom: 50px;
    padding-top: 20px;
    margin-top: 0;
 
    .el-row{
      margin: auto;
         margin-top: 35px;
      .el-col{
        .el-card{
          margin-left: 3px;
          margin-bottom: 3px;
        
          position: relative;
          &:hover h4{
            bottom: -22px;
            transition:all 0.5s ease;
          }
          span{
        
            h4{
              color: #ffffff;
            position: absolute;
            bottom:-105px;
            left: 0px;
            -webkit-line-clamp:1;
          
           overflow: hidden;
           text-overflow: ellipsis;
           -webkit-box-orient: vertical;
           
            font-weight: lighter;
           
            z-index: 100;
            overflow: hidden;
            padding: 20px 10px 40px 10px;
            background-color: rgba(0,0,0,0.52);
            &:hover{
              color: #ffffff;
            }
          
          }
          }
          
   
         
        }
      }
    }
  }
}
</style>
